/**
 * creater:chuanpeng.zhu@dhc.com.cn
 * create time:2016-05-30 16:58:36
 * describe:ActionSheet用作单选框
 */
APP.controller('ActionSheetController', ['$scope', 'ActionSheetService', '$ionicActionSheet',
  function ($scope, ActionSheetService, $ionicActionSheet) {

    /***变量声明***/
    $scope.question = undefined;
    $scope.optionButtons = undefined;

    /**
     * 初始化函数
     */
    $scope.init = function () {
      $scope.question = '什么样的节奏，最呀最摇摆？';
      $scope.optionButtons = [{text: '动次打次，动次打次'}, {text: '哒哒哒哒，哒哒哒哒'}];
    };

    /**
     * 登录方法
     */
    $scope.ActionSheetSubmit = function () {
      // Show the action sheet
      var hideSheet = $ionicActionSheet.show({
        buttons:$scope.optionButtons,
        destructiveText: '无可奉告',
        titleText: '选择你的答案',
        cancelText: '取消',
        cancel: function () {
          alert('你执行了取消操作');
        },
        buttonClicked: function (index) {
          alert('你选择了' + $scope.optionButtons[index].text);
          return true;
        },
        destructiveButtonClicked :function(){
          alert('年轻人，不要总想搞个大新闻，然后把我批判一番。我是身经百战的！');
        }

      });

    };


    /*
     $scope.init();//如果页面缓存则用此方法初始化
     */
    $scope.$on('$ionicView.beforeEnter', function () {
      $scope.init();
    });
  }
])
;

/**
 * creater:chuanpeng.zhu@dhc.com.cn
 * create time:2016-05-30 16:58:36
 * describe:ActionSheet用作单选框
 */
APP.service('ActionSheetService', ['$http', 'UrlService', function ($http, UrlService) {
  /**
   * 登录方法
   * @param username  登录用户名
   * @param password  登录密码
   */
  this.doLogin = function (username, password) {
    var param = {
      username: username,
      password: password
    };
    $http.post(UrlService.get('LOGIN'), param);
  }

}]);
